﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <div>
    <el-form ref="formRefIssueType" :model="stateIssueType.vmModel" label-width="100px">
      <el-row>
        <el-col :xs="24" :lg="24" class="mb20">
        <el-form-item ref="Entity_IssueName_FormItem" prop="Entity.IssueName" :label="$t('message.autotrans._Model_IssueType_IssueName')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_IssueType_IssueName')}), trigger: 'blur' }]" >
            <el-input v-model="stateIssueType.vmModel.Entity.IssueName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="24" class="mb20">
        <el-form-item ref="Entity_Code_FormItem" prop="Entity.Code" :label="$t('message.autotrans._Model_IssueType_Code')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_IssueType_Code')}), trigger: 'blur' }]" >
            <el-input v-model="stateIssueType.vmModel.Entity.Code" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="24" class="mb20">
        <el-form-item ref="Entity_ActiveColor_FormItem" prop="Entity.ActiveColor" :label="$t('message.autotrans._Model_IssueType_ActiveColor')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_IssueType_ActiveColor')}), trigger: 'blur' }]" >
            <el-input v-model="stateIssueType.vmModel.Entity.ActiveColor" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="24" class="mb20">
        <el-form-item ref="Entity_NormalColor_FormItem" prop="Entity.NormalColor" :label="$t('message.autotrans._Model_IssueType_NormalColor')"            :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_IssueType_NormalColor')}), trigger: 'blur' }]" >
            <el-input v-model="stateIssueType.vmModel.Entity.NormalColor" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="24" class="mb20">
        <el-form-item ref="Entity_Remark_FormItem" prop="Entity.Remark" :label="$t('message.autotrans._Model_IssueType_Remark')">
            <el-input v-model="stateIssueType.vmModel.Entity.Remark" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

      <div style="text-align:right;">
        <WtmButton @click="onSubmitIssueType"  type="primary" :button-text="$t('message.autotrans.SysSubmit')" style="margin-top:15px;"/>

        <WtmButton @click="onCloseIssueType"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

      </div>

    </el-form>

  </div>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageAndonManagementIssueTypeCreate;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { issuetypeApi } from '/@/api/andonmanagement/issuetype';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefIssueType = ref();
const stateIssueType = reactive({
    vmModel: {
	  Entity:{
        IssueName: '',
        Code: null,
        ActiveColor: '',
        NormalColor: '',
        Remark: '',
      },

	},
    
});

// 取消
const onCloseIssueType = () => {
    closeDialog();
};

// 提交
const onSubmitIssueType = () => {
 	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});
   formRefIssueType.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            issuetypeApi().add(stateIssueType.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
        else{
			loadingInstance.close();
        }
	})
};

// 页面加载时
onMounted(() => {
    
});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

